<template>
  <div class="common-layout">
    <el-container>
      <el-aside  class="sider-container" :width="aSideWidth">
        <div class="logo">
          <img src="../../../assets/logo.svg"> 言㐱陪诊 大数据展示系统
        </div>
        <el-menu
            default-active="1"
            class="el-menu-vertical-demo"
            background-color="#262626"
            router="router"
            text-color="#fff"
            :collapse="collapse"
        >
          <el-menu-item index="home">
            <el-icon>
              <House/>
            </el-icon>
            <span>首页</span>
          </el-menu-item>
          <el-menu-item index="login">
              <el-icon>
                <IEpMenu/>
              </el-icon>
              <span>切换登录账户</span>
          </el-menu-item>
          <el-sub-menu index="2">
            <template #title>
              <el-icon>
                <user/>
              </el-icon>
              <span>陪诊护士管理</span>
            </template>
            <el-menu-item index="escort">护士基本信息管理</el-menu-item>
          </el-sub-menu>
          <el-sub-menu index="3">
            <template #title>
              <el-icon>
                <user/>
              </el-icon>
              <span>客户管理</span>
            </template>
            <el-menu-item index="patient">客户基本信息管理</el-menu-item>
            <!--            <el-menu-item index="note">客户就诊信息管理</el-menu-item>-->
          </el-sub-menu>
          <el-sub-menu index="4">
            <template #title>
              <el-icon>
                <Location/>
              </el-icon>
              <span>预约管理</span>
            </template>
            <el-menu-item index="appointment">预约表信息管理</el-menu-item>
<!--            <el-menu-item index="appointment2">预约表信息管理2</el-menu-item>-->
          </el-sub-menu>
          <el-sub-menu index="5">
            <template #title>
              <el-icon>
                <Document/>
              </el-icon>
              <span>服务记录管理</span>
            </template>
            <el-menu-item index="serviceRecord">服务记录表信息管理</el-menu-item>
          </el-sub-menu>
          <el-sub-menu index="6">
            <template #title>
              <el-icon>
                <Setting/>
              </el-icon>
              <span>账号管理</span>
            </template>
            <el-menu-item index="user">全部账号管理</el-menu-item>
            <el-menu-item index="user0">管理员管理</el-menu-item>
            <el-menu-item index="user1">陪诊护士管理</el-menu-item>
            <el-menu-item index="user2">用户管理</el-menu-item>
          </el-sub-menu>

        </el-menu>
      </el-aside>
      <el-container>
        <el-header style="display: flex; justify-content: space-between; align-items: center;">
          <el-icon :size="20" color="#409efc">
            <Fold v-if="!collapse" @click="foldFn"/>
            <Expand v-else @click="expandFn"/>
          </el-icon>
          //头像位置
          <div class="avatar-container">
            <img src="../../../assets/touxiang.png" alt="头像">
          </div>
        </el-header>
        <el-main>
          <router-view></router-view>
        </el-main>
        <el-footer> 专业：计算机科学与技术 班级：计技222班 学号：2022102207 姓名：吴玉海 用于软件工程课程设计</el-footer>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import {Document, Expand, Fold, House, Location, Setting, User} from "@element-plus/icons-vue";
import {Menu as IEpMenu} from "@element-plus/icons-vue";

export default {
  components: {Fold, Expand, User, House, Setting, Document, Location, IEpMenu},
  data() {
    return {
      aSideWidth: '250px',
      collapse: false
    }
  },
  methods: {
    expandFn() {
      this.collapse = !this.collapse;
      this.aSideWidth = '250px'
    },
    foldFn() {
      this.collapse = !this.collapse;
      this.aSideWidth = '64px'

    }
  }
}
</script>

<style scoped>
.common-layout {
  height: 100%;
}

.el-container {
  height: 100%;
}

.el-aside {
  background-color: #262626;
  transition: width 800ms;
}

.logo {
  height: 60px;
  line-height: 60px;
  color: #40b782;
  overflow: hidden;
  padding-left: 12px;
}

.logo img {
  width: 40px;
  vertical-align: middle;
}

.el-menu {
  border: none;
}

.el-header {
  line-height: 60px;
  background-color: #191919;
}

.el-main {
  background-color: #FAFAFA;
}


.el-footer {
  height: 40px;
  line-height: 40px;
  background-color: #F0F2F5;
  color: #262626;
}

.avatar-container {
  img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
  }
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  margin-right: 10px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}
.common-layout {
  height: 100vh;
  background: #f0f2f5;
}

/* 侧边栏样式 */
.sider-container {
  background: #1a1a1a;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

.sider-container .logo-container {
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: #121212;
  overflow: hidden;
}

.sider-container .logo-container .logo-img {
  width: 36px;
  height: 36px;
  margin-right: 12px;
}

.sider-container .logo-container .logo-text {
  color: #40b782;
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
}

.sider-container .el-menu {
  border-right: none;
}

.sider-container .el-menu .el-menu-item,
.sider-container .el-menu .el-sub-menu__title {
  height: 48px;
  line-height: 48px;
  transition: all 0.3s;
}

.sider-container .el-menu .el-menu-item:hover,
.sider-container .el-menu .el-sub-menu__title:hover {
  background: rgba(64, 183, 130, 0.1) !important;
}

.sider-container .el-menu .el-menu-item:hover .menu-hover-effect,
.sider-container .el-menu .el-sub-menu__title:hover .menu-hover-effect {
  width: 100%;
}

.sider-container .el-menu .sub-menu-item {
  padding-left: 50px !important;
  background: #252525 !important;
}

.sider-container .el-menu .sub-menu-item:hover {
  background: rgba(64, 183, 130, 0.05) !important;
}

.menu-hover-effect {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, #40b782, #63e2b7);
  transition: width 0.3s;
}

/* 头部样式 */
.header-container {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.header-container .fold-icon {
  cursor: pointer;
  transition: transform 0.3s;
}

.header-container .fold-icon:hover {
  transform: scale(1.1);
}

.header-container .user-info {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.header-container .user-info .username {
  margin-left: 12px;
  font-size: 14px;
}

.header-container .user-info .avatar {
  transition: transform 0.3s;
}

.header-container .user-info .avatar:hover {
  transform: scale(1.1);
}

/* 主体内容 */
.main-container {
  padding: 20px;
}

.main-container .content-wrapper {
  background: #ffffff;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  min-height: calc(100vh - 120px);
}

/* 页脚样式 */
.footer-container {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  color: #666;
  font-size: 14px;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

.footer-container .footer-content {
  display: flex;
  align-items: center;
}

.footer-container .footer-content .el-divider {
  margin: 0 16px;
  background-color: #ddd;
}

/* 过渡动画 */
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

.fade-transform-enter-active,
.fade-transform-leave-active {
  transition: all 0.3s;
}

.fade-transform-enter-from {
  opacity: 0;
  transform: translateX(-30px);
}

.fade-transform-leave-to {
  opacity: 0;
  transform: translateX(30px);
}
</style>